package psd.model.Scala.Converters;

import java.util.List;

import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;

import psd.model.IConverter;
import psd.scala.FactDb;
import psd.scala.ScalaConverter;
import psd.scala.facts.FieldDefT;

public class ScalaFieldDeclarationConverter extends ScalaConverter implements
		IConverter<FieldDeclaration> {

	public ScalaFieldDeclarationConverter(FactDb fdb) {
		super(fdb);
	}

	@Override
	public boolean convert(FieldDeclaration node) {
		List list = node.fragments();
		int size = list.size();
		int id = node.hashCode();
		String lineNumber = this.getLineNumber(node);
		String path = this.getFilePath(node);
		int modifier = node.getModifiers();
		
		
		for (int i = 0; i < size; i++) {
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) list.get(i);
			FieldDefT fact = new FieldDefT(id, lineNumber, path, modifier, fragment.getName().toString());
			
			this.fdb.addFieldDef(fact);
		}

		return true;
	}

}
